<template>
	<view>
		<view class="bg-white">
			<u-tabs @click="clickTab" :scrollable="false" :list="list1" lineWidth="30" lineColor="#3389FF" :activeStyle="{
			            color: '#3389FF',
			            fontWeight: 'bold',
			            transform: 'scale(1.05)'
			        }" :inactiveStyle="{
			            color: '#606266',
			            transform: 'scale(1)'
			        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;">
			</u-tabs>
		</view>
		<view class="padding">
			<allList @projectAudit="projectAudit" :listData='dataList' isAudit showAuditState :entryStatus="0">
			</allList>
		</view>
		<u-back-top :scroll-top="scrollTop"></u-back-top>
		<u-loadmore v-show="dataList.length>0" :status="status" />
		<auditPop ref="auditPopRef" @popSuccess="search" :type="2"></auditPop>
	</view>
</template>

<script>
	import {
		listProjectInfo
	} from '@/utils/api.js'
	export default {
		data() {
			return {
				policyForm: {
					pageNum: 1,
					pageSize: 10,
					state: null
				},
				list1: [{
					name: '全部',
					state: null
				}, {
					name: '待审核',
					state: 1
				}, {
					name: '已通过',
					state: 0
				}, {
					name: '已退回',
					state: 2
				}],
				status: 'nomore',
				total: 0,
				dataList: [],
				scrollTop: 0
			}
		},
		onShow() {
			this.init()
		},
		onReachBottom() {
			if (this.policyForm.pageNum >= this.total / 10) {
				this.status = 'nomore'
				return
			} else {
				this.status = 'loading'
				this.policyForm.pageNum++
				this.init()
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods: {
			init() {
				uni.showLoading({
					title: '加载中'
				});
				listProjectInfo(this.policyForm).then(response => {
					if (response.code == 200) {
						uni.hideLoading();
						this.dataList = [...this.dataList, ...response.rows]
						this.total = response.total
					} else {
						uni.hideLoading();
						uni.showToast({
							title: response.msg,
							icon: 'none',
							duration: 3000
						})
					}
					this.status = 'nomore'
				});
			},
			clickTab(item) {
				this.policyForm.state = item.state
				this.policyForm.pageNum = 1
				this.dataList = []
				this.init()
			},
			projectAudit(item) {
				this.$refs.auditPopRef.openPop(item.baseId)
			},
			search() {
				this.policyForm.pageNum = 1
				this.dataList = []
				this.init()
			}
		}
	}
</script>
<style>
</style>